#ifndef __FOC_H
#define __FOC_H

#define TIM1_ARR TIM_CLK / PWM_FRQ
#define TIM_CLK 170000000
#define PWM_FRQ 10000
// #define PWM_FRQ 15000
#define M_PI (3.14159265358f)  // 圆周率
/*************电流计算相关宏定义************************/
#define ADC_REF_V   (float)(3.3f)                              //3.3V电压
#define AMP_GAIN    (double)(1.0f )                          //运放放大倍数
#define RES         (double)(0.005f)                           //采样电阻数值
#define K           (double)(ADC_REF_V / 4095.0f / AMP_GAIN)  //实际电压系数
/******************************************************/

typedef struct
{
	float I_q;
	float I_d;
	float I_alpha;
	float I_beta;
	float Ia;
	float Ib;
	float Ic;
	float Ud;
	float Uq;
	float U_alpha;
	float U_beta;
	float Ta;
	float Tb;
	float Tc;
	float theta;
	float Vbus;
	float Ki;
	float Kp;

} FOC_parame_;

void Control(void);
void Control_Current(void);

void Park(FOC_parame_ *foc);
void Clarke(FOC_parame_ *foc);
void R_park(FOC_parame_ *foc);
void SVPWM(FOC_parame_ *foc);
void printf_u(void);
#endif
